﻿/*
* ---------------------------------------------------
* 作者: MTQ 
* 日期： 2021/5/14 14:28:20 
* ---------------------------------------------------
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MTQ.BLL.UploadExcel;
using System.Web;
using NPOI.SS.UserModel;
using MTQ.Model;
using MTQ.BLL;
using MTQ.IBLL;
using MTQ.Common;
using System.Data;
namespace MTQ.BLL
{
    public partial class Log_LoginService : BaseService<Log_Login>
    {
        public IQueryable<Log_Login> LoadSearchData(Log_LoginQuery query)
        {
            var temp = _DbSession.Log_LoginRepository.LoadEntities(u => true);
            //可根据所需查询条件自行添加  

            if (!string.IsNullOrEmpty(query.Log_UserName))
            {
                temp = temp.Where<Log_Login>(u => u.Log_UserName.Contains(query.Log_UserName));
            }

            if (!string.IsNullOrEmpty(query.Log_LoginIP))
            {
                temp = temp.Where<Log_Login>(u => u.Log_LoginIP.Contains(query.Log_LoginIP));
            }

            if (!string.IsNullOrEmpty(query.Log_IpAddress))
            {
                temp = temp.Where<Log_Login>(u => u.Log_IpAddress.Contains(query.Log_IpAddress));
            }

            if (!string.IsNullOrEmpty(query.Log_Source))
            {
                temp = temp.Where<Log_Login>(u => u.Log_Source.Contains(query.Log_Source));
            }

            if (!string.IsNullOrEmpty(query.Log_BrowserInfo))
            {
                temp = temp.Where<Log_Login>(u => u.Log_BrowserInfo.Contains(query.Log_BrowserInfo));
            }

            if (!string.IsNullOrEmpty(query.Log_OsInfo))
            {
                temp = temp.Where<Log_Login>(u => u.Log_OsInfo.Contains(query.Log_OsInfo));
            }


            query.Total = temp.Count();
            return temp.OrderBy(u => u.Log_Id).Skip(query.PageSize * (query.PageIndex - 1)).Take(query.PageSize);
        }
        protected override IQueryable<Log_Login> GetBootstrapQueryable<K>(K paramterquery)
        {
            Log_LoginQuery query = paramterquery as Log_LoginQuery;
            IQueryable<Log_Login> temp = _DbSession.Log_LoginRepository.LoadEntities(u => true);


            if (!string.IsNullOrEmpty(query.Log_UserName))
            {
                temp = temp.Where<Log_Login>(u => u.Log_UserName.Contains(query.Log_UserName));
            }

            if (!string.IsNullOrEmpty(query.Log_LoginIP))
            {
                temp = temp.Where<Log_Login>(u => u.Log_LoginIP.Contains(query.Log_LoginIP));
            }

            if (!string.IsNullOrEmpty(query.Log_IpAddress))
            {
                temp = temp.Where<Log_Login>(u => u.Log_IpAddress.Contains(query.Log_IpAddress));
            }

            if (!string.IsNullOrEmpty(query.Log_Source))
            {
                temp = temp.Where<Log_Login>(u => u.Log_Source.Contains(query.Log_Source));
            }

            if (!string.IsNullOrEmpty(query.Log_BrowserInfo))
            {
                temp = temp.Where<Log_Login>(u => u.Log_BrowserInfo.Contains(query.Log_BrowserInfo));
            }

            if (!string.IsNullOrEmpty(query.Log_OsInfo))
            {
                temp = temp.Where<Log_Login>(u => u.Log_OsInfo.Contains(query.Log_OsInfo));
            }


            return temp;
        }

        public IQueryable<Log_Login> GetIQueryable(Log_LoginQuery query)
        {
            return this.GetBootstrapQueryable<Log_LoginQuery>(query);
        }
        public static bool ReadExcel(string filename, Guid userid, ref string msg)
        {
            return true;
        }


        public static void InsertLog(Log_Login log_Login) {
            Log_LoginService log_LoginService = new Log_LoginService();
            

            log_LoginService.AddEntity(log_Login);
        }

      
    }
}

